

	****************************************************
	
	* FIGURE A1: DISTRIBUTION OF ADMISSION CUTOFFS
	
	****************************************************

	use "$samplecutoffs", clear
	ttest bcomh, by(sample)
	ttest ecoh, by(sample)
	ksmirnov bcomh, by(sample)
	ksmirnov ecoh, by(sample)
	kdensity ecoh if sample==1, lcolor(gs0)  addplot(kdensity ecoh if sample==0, lcolor(gs0) lpattern(dash)) legend(order(1 "Sample colleges" 2 "Non-sample colleges") ///
		rows(1)) graphregion(fcolor(white))  title("(a) Economics") xtitle("") xlabel(, labsize(medsmall)) plotregion(lcolor(black) lwidth(thin))
		graph save "$out/cutecon", replace 
	kdensity bcomh if sample==1, lcolor(gs0) addplot(kdensity bcomh if sample==0, lcolor(gs0) lpattern(dash)) legend(order(1 "Sample colleges" 2 "Non-sample colleges") /// 
		rows(1)) graphregion(fcolor(white))  title("(b) Commerce") xtitle("") xlabel(, labsize(medsmall)) plotregion(lcolor(black) lwidth(thin))
		graph save "$out/cutbcomh", replace 
	
	* COMBINE FIGURES A1(a)-A1(b) INTO ONE GRAPH	
	grc1leg "$out/cutecon.gph" "$out/cutbcomh.gph", scheme(s1mono) rows(1) ycommon xcommon legendfrom("$out/cutecon.gph")
	graph export "$out/Fig_a1.pdf",  replace  //width(6000)

	erase "$out/cutecon.gph" 
	erase "$out/cutbcomh.gph"
	
	
	****************************************************

	* FIGURE A2 - A4: BALANCE IN BACKGROUND CHARACTERISTICS
	 
	****************************************************
	
	gl age "(a) Age"
	gl mod_edu_moth "(b) Mother's Education"
	gl mod_edu_fath "(c) Father's Education"
	gl hindu  "(d) Hindu"
	gl private_school "(e) Private School"
	gl lowinc "(f) Income"

	local control age mod_edu_moth mod_edu_fath  hindu private_school lowinc 
	
	* GENERATING FIGURE A2 : FULL SAMPLE
	use "$sample", clear
	keep if abs(runvar)<5 //keep analysis sample
		foreach var in `control'{
			bysort p25bins: egen mean_`var' = mean(`var') 
			twoway (qfit `var' runvar if runvar<0,clcolor(gs4) lpattern(solid)) ///
			(qfit `var' runvar if runvar>=0,clcolor(gs4) lpattern(solid)) ///
			(scatter mean_`var' p25bins, msize(medsmall) msymbol(circle) mfcolor(white) mlcolor(black) mlwidth(thin) xline(0, lcolor(grey) lpattern(dash))), ///
			ytitle("") xtitle(Distance to cutoff, size(medsmall) margin(small)) xlabel(, labsize(medsmall)) ///
			graphregion(fcolor(white)) legend(order(2 "Quadratic fit" 3 "0.25 bins") rows(1)) plotregion(lcolor(black) lwidth(thin)) title("$`var'")
			graph save "$out/`var'_full", replace
		}
		
	* COMBINE FIGURES A2(a)-A2(f) INTO ONE GRAPH
	* The following requires the program "grc1leg" by Vince Wiggins
	* This is availble in STATA by typing - findit grc1leg - and then installing	
	grc1leg "$out/age_full.gph" "$out/mod_edu_moth_full.gph" "$out/mod_edu_fath_full.gph" "$out/hindu_full.gph"  "$out/private_school_full.gph" "$out/lowinc_full.gph", ///
		scheme(s1mono) rows(2) legendfrom("$out/hindu_full.gph")
	graph export "$out/Fig_a2.pdf",  replace  //width(6000)
	
	erase "$out/age_full.gph" 
	erase "$out/mod_edu_moth_full.gph" 
	erase "$out/mod_edu_fath_full.gph" 
	erase "$out/hindu_full.gph"  
	erase "$out/private_school_full.gph" 
	erase "$out/lowinc_full.gph"
	
	
	* GENERATING FIGURE A3 : MALES
	use "$sample", clear
	keep if abs(runvar)<5
	keep if fem==0
		foreach var in `control'{
			bysort p25bins: egen mean_`var' = mean(`var') 
			twoway (qfit `var' runvar if runvar<0,clcolor(gs4) lpattern(solid)) ///
			(qfit `var' runvar if runvar>=0,clcolor(gs4) lpattern(solid)) ///
			(scatter mean_`var' p25bins, msize(medsmall) msymbol(circle) mfcolor(white) mlcolor(black) mlwidth(thin) xline(0, lcolor(grey) lpattern(dash))), ///
			ytitle("") xtitle(Distance to cutoff, size(medsmall) margin(small)) xlabel(, labsize(medsmall)) ///
			graphregion(fcolor(white)) legend(order(2 "Quadratic fit" 3 "0.25 bins") rows(1)) plotregion(lcolor(black) lwidth(thin)) title("$`var'")
			graph save "$out/`var'_male", replace
		}
		
	* COMBINE FIGURES A3(a)-A3(f) INTO ONE GRAPH	
	grc1leg "$out/age_male.gph" "$out/mod_edu_moth_male.gph" "$out/mod_edu_fath_male.gph" "$out/hindu_male.gph" "$out/private_school_male.gph" "$out/lowinc_male.gph", /// 
		scheme(s1mono) rows(2) legendfrom("$out/hindu_male.gph")
	graph export "$out/Fig_a3.pdf",  replace  //width(6000)
	
	erase "$out/age_male.gph" 
	erase "$out/mod_edu_moth_male.gph" 
	erase "$out/mod_edu_fath_male.gph" 
	erase "$out/hindu_male.gph" 
	erase "$out/private_school_male.gph" 
	erase "$out/lowinc_male.gph"
	
	* GENERATING FIGURE A4 : FEMALES
	use "$sample", clear
	keep if abs(runvar)<5
	keep if fem==1
		foreach var in `control'{
			bysort p25bins: egen mean_`var' = mean(`var') 
			twoway (qfit `var' runvar if runvar<0,clcolor(gs4) lpattern(solid)) ///
			(qfit `var' runvar if runvar>=0,clcolor(gs4) lpattern(solid)) ///
			(scatter mean_`var' p25bins, msize(medsmall) msymbol(circle) mfcolor(white) mlcolor(black) mlwidth(thin) xline(0, lcolor(grey) lpattern(dash))), ///
			ytitle("") xtitle(Distance to cutoff, size(medsmall) margin(small)) xlabel(, labsize(medsmall)) ///
			graphregion(fcolor(white)) legend(order(2 "Quadratic fit" 3 "0.25 bins") rows(1)) plotregion(lcolor(black) lwidth(thin)) title("$`var'")
			graph save "$out/`var'_female", replace
		}
	
	* COMBINE FIGURES A3(a)-A3(f) INTO ONE GRAPH	
	grc1leg "$out/age_female.gph" "$out/mod_edu_moth_female.gph" "$out/mod_edu_fath_female.gph" "$out/hindu_female.gph"  "$out/private_school_female.gph" "$out/lowinc_female.gph", /// 
		scheme(s1mono) rows(2) legendfrom("$out/hindu_female.gph")
	graph export "$out/Fig_a4.pdf", replace  //width(6000)
	
	
	erase "$out/age_female.gph" 
	erase "$out/mod_edu_moth_female.gph" 
	erase "$out/mod_edu_fath_female.gph" 
	erase "$out/hindu_female.gph"  
	erase "$out/private_school_female.gph" 
	erase "$out/lowinc_female.gph"
